/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.session;

import edu.fpt.entity.Employee;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author TuanAnh
 */
@Stateless
public class EmployeeFacade extends AbstractFacade<Employee> implements EmployeeFacadeLocal {

    @PersistenceContext(unitName = "ProjectManagementHotel-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public EmployeeFacade() {
        super(Employee.class);
    }

    @Override
    public boolean checkLogin(String id, String pin) {
        boolean ck = false;
        try {
            List<Employee> list = findAll();
            for (Employee em : list) {
                if (em.getEmployeeId().equals(id) && em.getPassword().equals(pin)) {
                    ck = true;
                }
            }
        } catch (Exception ex) {
        }
        return ck;
    }
}
